let urlSearchParams;
const getUrlSearchParams = (key = null) => {
  if (!urlSearchParams) {
    urlSearchParams = new URLSearchParams(location.href);;
  }
  return key ? urlSearchParams.get(key) : urlSearchParams;
};

const getParams = (locationSearch) => {
  var result = {};
  var searchStr = locationSearch || window.location.search;
  var paramster = searchStr.split('?');

  if (paramster.length > 1) {
    var hrefStr = paramster[1];
    var paramArr = hrefStr.split('&');
    for (var i = 0; i < paramArr.length; i++)
      result[paramArr[i].split('=')[0]] = paramArr[i].split('=')[1];
  }

  return result;
};
export {
  getUrlSearchParams,
  getParams
};
